home *** CD-ROM | disk | FTP | other *** search
- //ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
- // YELLOW EXTENSION TOOLKIT
- // File Name : YE main.c
- // ⌐ 1998 by Rocco Moliterno. All Right Reserved
- //ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
-
- #include "WASTE.h"
- // In order to use Waste functions, you need to add WASTE and the Libraries WASTE requires
-
- #include "YE proto.h"
- #include "YE main.h"
-
- #if GENERATING68K
- #include <SetUpA4.h>
- #include <A4Stuff.h>
- #else
- ProcInfoType __procinfo = uppYellowEntryProcInfo;
- #endif
-
- pascal void main(YEBlockPtr params)
- {
- #if GENERATING68K
- EnterCodeResource();
- #endif
-
- //---------------------------your code here
-
- GoAction(params);
-
- //---------------------------end your code
-
- #if GENERATING68K
- ExitCodeResource();
- #endif
-
- }
-
- #pragma mark EXAMPLE CODE
-
- void GoAction(YEBlockPtr params)
- {
-
- // Sanity: YellowEdit requires always params->signature = 'yllw'
- if(params->signature==yellowSignature){
- ParamText("\pYellow Extension sanity check: good, YellowEdit calls me!" ,"\p", "\p", "\p");
- NoteAlert(128, nil);
- }
- else // The caller isn't YellowEdit, we return, unless if you're writing
- return; // the extension for another application, or else you perform a job
- // without considering the caller.
-
- // Unless we modify directly input data, we can ignore, here, any inputs parameters then
- // make our job: display alert/dialog, play sound, get file, play game and so on.
- // We MUST always check the input parameters if we want to modify directly some
- // data ex:
- //
- // if(params->sFile)
- // if((iErr=ResolveAlias(nil,params->sFile, &target, &wasChanged))!=noErr)
- // iErr=FSpDelete(&target);
- //
- // or else:
- // if(params->sWaste)
- // WEPaste(params->sWaste);
- // in the following example, we don't modify directly any data but we make checks for security.
-
-
- // Remember: the calling application has responsibility to dispose any valid but unused,
- // handle returned by extensions.
- //----------------------------------------------------------------------------------
- if( (!params->sWaste) &&
- (!params->sText) &&
- (!params->sFile) &&
- (!params->sList)){
- ParamText("\pOh no! there's no window open!! I will return some text into a new window","\p" ,"\p" , "\p");
- NoteAlert(128, nil);
- params->rNew=true; //put new TEXT into a new window.
- }
-
- if(params->sWaste || params->sText){
- ParamText( "\pThe call contains a valid text-related request","\p" ,"\p" , "\p");
- NoteAlert(128, nil);
-
- ParamText("\pI will return some text to existing window...","\p" ,"\p" , "\p" );
- NoteAlert(128, nil);
- }
-
- params->rText=GetResource('TEXT',128);
- DetachResource(params->rText);
- HLock(params->rText);
- params->rStyles=GetResource('styl',128);
- DetachResource(params->rStyles);
- HLock(params->rStyles);
-
- if(params->sFile){
- Boolean wasChanged;
- FSSpec target;
- if(ResolveAlias(nil,params->sFile, &target, &wasChanged)==noErr)
- ParamText( "\pThe call contains an AliasHandle:",target.name , "\p" , "\p");
- else
- ParamText( "\pThe call contains an AliasHandle, but can't resolve this damned alias!","\p" , "\p" , "\p");
- NoteAlert(128, nil);
- }
-
- if(params->sList){
- ParamText("\pThe call contains a List Handle","\p" ,"\p" , "\p");
- NoteAlert(128, nil);
- }
-
- }
-
-